package com.mall.product.service.impl;

import com.mall.entity.TbSpecOption;
import com.mall.entity.TbSpeclification;
import com.mall.product.mapper.SpecOptionMapper;
import com.mall.product.mapper.SpeclificationMapper;
import com.mall.product.service.SpecOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 规范选择服务impl
 * created with IntelliJ IDEA
 *
 * @author ASUS
 * @Auther: W
 * @Date: 2021/07/16/15:34
 * Other:
 * @date 2021/07/18
 */
@Service
public class SpecOptionServiceImpl implements SpecOptionService {

    @Autowired
    private SpecOptionMapper specOptionMapper;

    @Autowired
    private SpeclificationMapper speclificationMapper;

    @Override
    public List<TbSpecOption> findById(Integer specId) {
        return specOptionMapper.findById(specId);
    }

    @Override
    public TbSpeclification findByIdAll(Integer id) {
        TbSpecOption tbSpecOption = specOptionMapper.findOne(id);
        TbSpeclification speclification = speclificationMapper.findONeById(tbSpecOption.getSpecId());

        speclification.setSpecOptionList(specOptionMapper.findById(speclification.getId()));
        return speclification;
    }
}
